/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Pop_up_item_details.java
 *
 * Created on 25 September 2010, 10:56:37 PM
 */

package CAT200;
import java.util.*;
/**
 *
 * @author Wai Hong
 */
public class Pop_up_item_details extends javax.swing.JFrame {

    double PRICE;
    String PRO_PRICE;
    /** Creates new form Pop_up_item_details */
    public Pop_up_item_details(String id, String address, String description, String price, String size, String color) {
        initComponents();

        productImage.setIcon(new javax.swing.ImageIcon(address));
        productID.setText(id);
        productDescription.setText(description);
        productPrice.setText(price);
        productSize.setText(size);
        productColor.setText(color);
        PRO_PRICE = price;

        setLocationRelativeTo(null);
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        productImage = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        ORDER = new javax.swing.JButton();
        CANCEL = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        productID = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        productDescription = new javax.swing.JTextArea();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        productPrice = new javax.swing.JLabel();
        productSize = new javax.swing.JLabel();
        productColor = new javax.swing.JLabel();
        productQuantity = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Item Details", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        productImage.setIcon(new javax.swing.ImageIcon(getClass().getResource(""))); // NOI18N

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel6.setText("Quantity :");

        ORDER.setText("Order");
        ORDER.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ORDERActionPerformed(evt);
            }
        });

        CANCEL.setText("Cancel");
        CANCEL.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CANCELActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel2.setText("Product ID  :");

        productID.setFont(new java.awt.Font("Tahoma", 0, 12));
        productID.setText("jLabel3");

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel4.setText("Product Description  :");

        productDescription.setColumns(20);
        productDescription.setEditable(false);
        productDescription.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        productDescription.setLineWrap(true);
        productDescription.setRows(5);
        productDescription.setWrapStyleWord(true);
        jScrollPane1.setViewportView(productDescription);

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel3.setText("Size  :");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel5.setText("Color  :");

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel7.setText("Price  :");

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel8.setText("RM");

        productPrice.setFont(new java.awt.Font("Tahoma", 0, 12));
        productPrice.setText("jLabel9");

        productSize.setText("jLabel1");

        productColor.setText("jLabel9");

        productQuantity.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4" }));
        productQuantity.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                productQuantityActionPerformed(evt);
            }
        });
        productQuantity.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                productQuantityPropertyChange(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(productImage)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel2)
                            .addComponent(jLabel4)
                            .addComponent(jLabel3)
                            .addComponent(jLabel5)
                            .addComponent(jLabel7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(productID)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(productPrice))
                            .addComponent(productSize)
                            .addComponent(productColor)
                            .addComponent(productQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(CANCEL)
                        .addGap(18, 18, 18)
                        .addComponent(ORDER)
                        .addGap(115, 115, 115))))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {CANCEL, ORDER});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(productImage, javax.swing.GroupLayout.PREFERRED_SIZE, 317, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(productID))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(productQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(productSize))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(productColor))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(jLabel8)
                            .addComponent(productPrice))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ORDER)
                    .addComponent(CANCEL)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>

    private void CANCELActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
        this.dispose();
    }                                      

    private void productQuantityPropertyChange(java.beans.PropertyChangeEvent evt) {                                               
        // TODO add your handling code here:
    }                                              

    private void productQuantityActionPerformed(java.awt.event.ActionEvent evt) {                                                
        // TODO add your handling code here:
        String PRODUCTPRICE = (String)productQuantity.getSelectedItem();
        String newPrice;

             if(PRODUCTPRICE.equals("1"))
             {
                 PRICE = Double.parseDouble(PRO_PRICE);
                 PRICE = PRICE * 1;
                 newPrice = String.valueOf(PRICE);
                 productPrice.setText(newPrice);
             }

             else if(PRODUCTPRICE.equals("2"))
             {
                 PRICE = Double.parseDouble(PRO_PRICE);
                 PRICE = PRICE * 2;
                 newPrice = String.valueOf(PRICE);
                 productPrice.setText(newPrice);
             }
             else if(PRODUCTPRICE.equals("3"))
             {
                 PRICE = Double.parseDouble(PRO_PRICE);
                 PRICE = PRICE * 3;
                 newPrice = String.valueOf(PRICE);
                 productPrice.setText(newPrice);
             }
             else if(PRODUCTPRICE.equals("4"))
             {
                 PRICE = Double.parseDouble(PRO_PRICE);
                 PRICE = PRICE * 4;
                 newPrice = String.valueOf(PRICE);
                 productPrice.setText(newPrice);
             }
    }                                               

    private void ORDERActionPerformed(java.awt.event.ActionEvent evt) {                                      
        // TODO add your handling code here:
        First_Menu.productDetail = new Vector<String>();

        First_Menu.productDetail.addElement(productID.getText());

        String QUANTITY = (String)productQuantity.getSelectedItem();
        if(QUANTITY.equals("1"))
            First_Menu.productDetail.addElement("1");
        else if(QUANTITY.equals("2"))
            First_Menu.productDetail.addElement("2");
        else if(QUANTITY.equals("3"))
            First_Menu.productDetail.addElement("3");
        else if(QUANTITY.equals("4"))
            First_Menu.productDetail.addElement("4");

        First_Menu.productDetail.addElement(productSize.getText());
        First_Menu.productDetail.addElement(productColor.getText());
        First_Menu.productDetail.addElement(productPrice.getText());

        First_Menu.productData.add(First_Menu.productDetail);

        javax.swing.JOptionPane.showMessageDialog(null,"Product added!");
        this.dispose();
        new Order_Sumarry().setVisible(true);
    }                                     

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Pop_up_item_details("", "", "", "", "", "").setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JButton CANCEL;
    private javax.swing.JButton ORDER;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel productColor;
    private javax.swing.JTextArea productDescription;
    private javax.swing.JLabel productID;
    private javax.swing.JLabel productImage;
    private javax.swing.JLabel productPrice;
    private javax.swing.JComboBox productQuantity;
    private javax.swing.JLabel productSize;
    // End of variables declaration

}
